<?php

class Core_Backend_Component_Permission_View_Role_Index extends Core_Backend_Share_View_Grid {

    protected function buildToolbar($toolbar) {
    	parent::buildToolbar($toolbar);
    	$group = $toolbar->createGroup();
            $group->addButton($this->__('share.button.delete'))
                    ->bindEvent('click', "submitGridChecked('" . $this->getGrid()->getId() . "', '" . $this->getUrl(NULL, 'delete') . "')");
        $group->addLink($this->getUrl(NULL, 'create'), $this->__('share.button.create'));
    }

    protected function buildGrid($grid) {
    	$this->getTemplate()->assignMulti(array('areas'=>$this->getAreas(), 'current_area_id'=>$this->getCurrentAreaId()));
        $filter = new Kd_Object($this->getRequest()->getParameter('filter'));
        $grid->setId('role_grid')
                ->setPrimaryKey('id');
        $grid->addLabelColumn($this->__('share.label.code'), 'code', '{code}')
                ->setWidth(200);
        $grid->addLabelColumn($this->__('share.label.name'), 'name', '{name}')
                ->setWidth(200);
        $grid->addLabelColumn($this->__('share.label.status'), 'status', '{{lang "status.enable.{status}"}}')
                ->setWidth(200);
        $grid->addLinkColumn('#', 'edit', $this->getUrl(array('id' => '{id}'), 'edit'), $this->__('share.button.edit'))
                ->setWidth(40)
                ->setAlign('center');
        $grid->setDataSource($this->getList()->toArray());
        parent::buildGrid($grid);
    }

    protected function buildPagination($pagination) {
        $url = $this->getPaginationUrl(array('areaid'=>$this->getCurrentAreaId()));
        $pagination->setUrlFormat($url)
                ->setRecordCount($this->getRecords());
        parent::buildPagination($pagination);
    }

}